<!DOCTYPE html>
<html lang="en">

<head>
    <meta charset="UTF-8">
    <meta http-equiv="X-UA-Compatible" content="IE=edge">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>箭头函数</title>
</head>

<body>
    <p id="demo"></p>
    <p id="demo2"></p>
    <p id="demo3"></p>

    <script>
        {
            let hello;
            /*   hello = () => {
                  return "Hello World!";
              } */
            //如果函数只有一个语句，并且该语句返回一个值，则可以去掉括号和 return 关键字
            hello = () => "Hello World!";
            document.getElementById("demo").innerHTML = hello();
        } {
            let hello;
            hello = (val) => "Hello " + val;
            document.getElementById("demo2").innerHTML = hello("Universe!");
        } {
            let hello;
            hello = val => "Hello " + val;//只有一个参数也可以略过括号
            document.getElementById("demo3").innerHTML = hello("College!");
        }
    </script>
</body>

</html>